const Gio = imports.gi.Gio;
const Lang = imports.lang;
-const UPowerGlib = imports.gi.UPowerGlib;
const LoginManager = imports.misc.loginManager;
_init: function() {
/* Translators: accessible name of the power menu in the login screen */
this.parent('system-shutdown-symbolic', _("Power"));
- this._upClient = new UPowerGlib.Client();
this._loginManager = LoginManager.getLoginManager();
this._createSubMenu();
- this._upClient.connect('notify::can-suspend',
- Lang.bind(this, this._updateHaveSuspend));
- this._updateHaveSuspend();
-
// ConsoleKit doesn't send notifications when shutdown/reboot
// are disabled, so we update the menu item each time the menu opens
this.menu.connect('open-state-changed', Lang.bind(this,
if (open) {
this._updateHaveShutdown();
this._updateHaveRestart();
+ this._updateHaveSuspend();
}
}));
this._updateHaveShutdown();
this._updateHaveRestart();
+ this._updateHaveSuspend();
},
_updateVisibility: function() {
},
_updateHaveSuspend: function() {
- this._haveSuspend = this._upClient.get_can_suspend();
- this._suspendItem.actor.visible = this._haveSuspend;
- this._updateVisibility();
+ this._loginManager.canSuspend(Lang.bind(this, function(result) {
+ this._haveSuspend = result;
+ this._suspendItem.actor.visible = this._haveSuspend;
+ this._updateVisibility();
+ }));
},
_createSubMenu: function() {
},
_onActivateSuspend: function() {
- if (this._haveSuspend)
- this._upClient.suspend_sync(null);
+ if (!this._haveSuspend)
+ return;
+
+ this._loginManager.suspend();
},
_onActivateRestart: function() {